﻿using System;
using System.Globalization;
using System.Windows.Data;
using System.Windows.Media;

namespace FunasrSTT.Translate.Converters;

/// <summary>
/// 对话框类型转换成画刷.
/// </summary>
public class DialogKindToBrushConverter : IValueConverter
{
    private static readonly SolidColorBrush _helpBrush        = new(Color.FromRgb(0, 188, 212));
    private static readonly SolidColorBrush _informationBrush = new(Color.FromRgb(50, 108, 243));
    private static readonly SolidColorBrush _successBrush     = new(Color.FromRgb(45, 184, 77));
    private static readonly SolidColorBrush _warningBrush     = new(Color.FromRgb(233, 175, 32));
    private static readonly SolidColorBrush _errorBrush       = new(Color.FromRgb(219, 51, 64));

    /// <inheritdoc />
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        if (value is ViewModels.DialogKind kind)
        {
            return kind switch
            {
                ViewModels.DialogKind.Help        => _helpBrush,
                ViewModels.DialogKind.Information => _informationBrush,
                ViewModels  .DialogKind.Success     => _successBrush,
                ViewModels.DialogKind.Warning     => _warningBrush,
                ViewModels.DialogKind.Error       => _errorBrush,
                _                      => _informationBrush,
            };
        }

        return _informationBrush;
    }

    /// <inheritdoc />
    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        return ViewModels.DialogKind.Information;
    }
}
